class ProtocolError(Exception):
    pass
class ProtocolAuthError(ProtocolError):
    pass

class BaseDB(object):
    __slots__ = ["filename"]
    def __init__(self, filename):
        self.filename = filename
    
    @classmethod
    def load(cls, filename):
        inst = cls._load(open(filename, "r").read())
        inst.filename = filename
        return inst

    def save(self, filename = None):
        if not filename:
            filename = self.filename
        f = open(filename, "w")
        f.write(self._dump())
        f.close()




